<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
#parse("/WEB-INF/views_webapp/layout/css.html")
#parse("/WEB-INF/views_webapp/layout/base.html")
<title>咕哒猎人</title>
</head>
<body class="paysuccess">
	<div class="paysuccess">
		<span class="paysuccess1" style="font-size: 2rem"><span id="nickName"></span>, 欢迎进入咕哒猎人!</span>
		<span class="paysuccess2" style="font-size: 3rem" onclick="scan()">扫一扫</span>
	</div>
	<div id="pybott">
		<img src="${base}/static/res/webapp/img/bg.png" class="img" />
	</div>
#parse("/WEB-INF/views_webapp/layout/bottom.html")
<script type="text/javascript" src="http://g.alicdn.com/ilw/ding/0.7.3/scripts/dingtalk.js"></script>

<script type="text/javascript">
	function scan(){
		dd.biz.util.scan({
		    type: "qrCode",
		    onSuccess: function(data) {
		    	window.location.href = data.text + "?type=login&userId=" + userId + "&nickName=" + nickName + "&corpId=" + corpId;
		    },
		   onFail : function(err) {
			   alert("扫描二维码失败!");
		   }
		});
	} 
</script>

<script type="text/javascript">
var _config = ${config};
var userId = "";
var nickName = "";
var corpId = _config.corpId;

dd.config({
			agentId : _config.agentid,
			corpId : _config.corpId,
			timeStamp : _config.timeStamp,
			nonceStr : _config.nonceStr,
			signature : _config.signature,
			jsApiList : [ 'runtime.info', 'biz.contact.choose',
					'device.notification.confirm', 'device.notification.alert',
					'device.notification.prompt', 'biz.ding.post',
					'biz.util.openLink','biz.user.get',"biz.util.scan" ]
});

dd.ready(function() {
	dd.runtime.info({
		onSuccess : function(info) {
		},
		onFail : function(err) {
			alert('fail-runtime: ' + JSON.stringify(err));
		}
	});

	dd.biz.user.get({
	    onSuccess: function (info) {
	    	userId= info.id;
	    	nickName = info.nickName;
	    	corpId = info.corpId;
	    	document.getElementById("nickName").innerHTML = nickName;
	    },
	    onFail: function (err) {
	    	alert("错误:"+JSON.stringify(err));
	    }
	});
});

dd.error(function(err) {
	alert('钉钉发生错误: ' + JSON.stringify(err));
});
</script>
</body>
</html>